
  <template>
  <div class="bf-commont-template">
    <!-- <div style="padding: 0 16px ;">
      <h3>消息通知</h3>
      <p>该页面代码已经自动生成，按照普通码 表增删改查 为基础生成模板</p>
      <p>生成代码对应的 vue 文件路径：D:\Zmyitem\vue-element-admin\src\beneform4j\view\parammanager\news\news.vue</p>
      <el-alert title="注意：表格内数据为模拟数据, 如果数据格式不对，请先进行格式转换。 模拟数据文件路径：src/mock/demo.js" type="warning"> </el-alert>
    </div> -->
    <div class="clearfix bf-top-button">
      <div class="float-l">
        <el-button @click="showAdd" type="primary">新增</el-button>
      </div>
      <div class="float-r">
        <div class="float-l">
          <el-input
            placeholder="请输入搜索内容"
            prefix-icon="el-icon-search"
            v-model="searchData"
            @keyup.enter.native="quickSearch"
          ></el-input>
        </div>
        <div class="float-l padding-l">
          <el-button @click="showSearch" type="primary">高级筛选</el-button>
        </div>
      </div>
    </div>
    <bf-table
      :data="userData"
      :setting="newsSetting"
      :rowAction="rowAction"
      @editSubmit="editSubmit"
      @pageChange = "pageChange"
      ref="table"
    ></bf-table>
    <div class="form-box">
      <div>
        <bf-table-edit
          :width="940"
          :title="'新增消息公告'"
          ref="bfTableEdit"
          :editForm="newsSetting"
          :rowNum="2"
          @formSubmit="addSubmit"
          :editRules="editRules"></bf-table-edit>
      </div>
    </div>
  </div>
</template>

<script>

import { newsSetting } from './setting'
import { getListApi, addNewsApi } from './api'
export default {
  data() {
    return {
      newsSetting: newsSetting,
      postForm: {},
      rules: {},
      content: '',
      searchData: '',
      userData: {
      },
      rowAction: [
        {
          label: '查看',
          click: (item) => {
            this.$refs.table.showDetail(item)
          }
        },
        {
          label: '编辑',
          click: (item) => {
            this.$refs.table.showEdit(item)
          }
        },
        {
          label: '删除',
          click: (item) => {
            this.$refs.table.showDelete(item)
          }
        }
      ],
      editRules: {
        msgTitle: [
          { required: true, message: '必填项', trigger: 'blur' },
        ],
        msgType: [
          { required: true, message: '必填项', trigger: 'blur' },
        ]
      }
    }
  },
  mounted: function() {
    this.searchList({
      page: 1
    })
  },
  methods: {
    addNews(params) {
      addNewsApi(params).then(response => {
        // console.log(response)
      })
    },
    addSubmit(form) {
      // console.log(form)
      this.addNews(form)
    },
    doSubmit() {
      this.$refs.bfTableEdit.show({})
    },
    draftForm() {},
    loading() {},
    platformsOptions(){},
    isEdit() {

    },
    fetchSuccess() {},
    searchList(params) {
      getListApi(params).then(response => {
        if (response.success) {
          this.userData = response
        }
      })
    },
    editSubmit(params) {
      // console.log(params)
    },
    pageChange(pageObj) {
      // console.log(pageObj)
    },
    showSearch() {
      this.$refs.table.showSearch()
    },
    showAdd() {
      this.$refs.bfTableEdit.show({})
    },
    quickSearch() {
      // const params = {
      //   userId: this.searchData
      // }
      // console.log(params)
    }
  }
}
</script>

<style scoped>
.form-box{
  padding: 20px 16px;
}
</style>
